import {Component, OnInit} from '@angular/core';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
  title = 'app';


  ngOnInit() {
    // this.orient();
  }

  // 判断设备是否横屏
  orient() {
    if (window.orientation === 0 || window.orientation === 180) {
      $('body').attr('class', 'portrait');  // 当竖屏的时候为body增加一个class
      orientation = 'portrait';
      return false;
    } else if (window.orientation === 90 || window.orientation === -90) {
      $('body').attr('class', 'landscape'); // 当横屏的时候为body移除这个class
      orientation = 'landscape';

      return false;
    }
  }
}
